package com.luci.util;

import com.alibaba.fastjson.JSON;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import lombok.Cleanup;
import org.springframework.http.MediaType;

/**
 * jwt工具类
 *
 * @author yuyanan
 * @version 1.0
 * @date 18-11-22
 */
public class HttpServletResponseUtils {

    public static void responseWrite(HttpServletResponse response, Object obj) throws IOException {
        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
        response.setStatus(HttpServletResponse.SC_OK);
        response.setCharacterEncoding("utf-8");
        @Cleanup PrintWriter out = response.getWriter();
        out.write(JSON.toJSONString(obj));
        out.flush();
    }

}
